<!DOCTYPE>
<html>
    <head>
        <meta charset='utf-8'>
        <script src="esl.js"></script>
        <script src="config.js"></script>
        <script src="lib/jquery.min.js"></script>
    </head>
    <body>
        <style>
            html, body, #main {s
                width: 100%;
                height: 100%;
            }
        </style>
        <div id="main"></div>
        <script>

            require([
                'echarts',
                'ecStat'
            ], function (echarts, ecStat) {

                var chart = echarts.init(document.getElementById('main'));

                var data = [
                    [0, 0],
                    [1, 2],
                    [2, 3],
                    [3, 4],
                    [4, 5],
                    [5, 8],
                    [6, 7],
                    [7, 7],
                    [8, 10],
                    [9, 14],
                    [10, 10],
                    [11, 11],
                    ['12', '12'],
                    [13, 15]
                ];

                var myRegression = ecStat.regression('linearThroughOrigin', data);

                myRegression.points.sort(function (a, b) {
                    return a[0] - b[0];
                });

                chart.setOption({
                    legend: {
                        data: ['scatter', 'line']
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross'
                        }
                    },
                    xAxis: {
                        type: 'value',
                        splitLine: {
                            show: false
                        },
                        splitNumber: 20
                    },
                    yAxis: {
                        type: 'value',
                        splitLine: {
                            show: false
                        }
                    },
                    series: [{
                        name: 'scatter',
                        type: 'scatter',
                        label: {
                            emphasis: {
                                show: true
                            }
                        },
                        data: data
                     },{
                        name: 'line',
                        type: 'line',
                        showSymbol: false,
                        data: myRegression.points
                    }]
                });
            });
        </script>
    </body>
</html>